#ifndef OPEDB_H
#define OPEDB_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>

class OpeDB : public QObject
{
    Q_OBJECT
public:
    explicit OpeDB(QObject *parent = nullptr);

    ~OpeDB();

    static OpeDB& getInstence();

    void init_db();

    bool handle_regist(const char* name, const char* pwd);
    bool handle_login(const char* name, const char* pwd);
    bool handle_logout(const char* name);
    QStringList handle_show_online();
    int handle_search_user(const char* name);
    int handle_add_friend(const char* my_name, const char* user_name);
    void handle_add_friend_agree(const char* my_name, const char* user_name);
    int handle_del_friend(const char* my_name, const char* user_name);
    QStringList handle_flush_friend(const char* name);

    int handle_get_userID(const char *name);

private:
    QSqlDatabase m_db;
signals:
};

#endif // OPEDB_H

/*
create table userInfo(id integer primary key autoincrement,
 name varchar(32) unique,
 pwd varchar(32),
 online integer default 0);

*/
